package com.lanou3g.code0510.mvc;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;

/**
 * If there are no bugs, it was created by Chen FengYao on 2018/5/10;
 * Otherwise, I don't know who created it either
 */

public class View {
    private Controller controller;

    public View() {
        Properties properties = new Properties();
        try {

            InputStream is = new
                    FileInputStream("conf.properties");
            properties.load(is);
            // 通过反射来创建对象
            String clazzName = properties.getProperty("controller");
            Class clazz = Class.forName(clazzName);
            controller = (Controller) clazz.newInstance();
            is.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    public void login() {
        controller.login();
    }

    public static void main(String[] args) {
        View view = new View();
        view.login();
    }
}
